// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const SexType = cc.Enum({
  未知: 0,
  男: 1,
  女: 2
});

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

  @property(cc.Label)
  label: cc.Label = null;

  @property
  text: string = 'hello';

  // 性别  enum类型
  @property({ type: SexType, displayName: "性别" })
  sex = SexType.未知;

  // 年龄 sex为男的时候显示
  @property({ type: Number, visible() { return this.sex === SexType.未知 } })
  age = 20

  // 滑动条
  @property({ type: Number, slide: true, min: 0, max: 120, step: 1, tooltip: '滚动条' })
  score = 0

  // 回调函数
  // 要想在属性面板绑定回调函数，需设置属性的type为cc.Component.EventHandler，设置默认值为空，并且在构造函数中初始化属性为cc.Component.EventHandler的实例。
  @property(cc.Component.EventHandler)
  color = null


  
  // LIFE-CYCLE CALLBACKS:

  // onLoad () {}

  start() {
    this.color = new cc.Component.EventHandler()
  }

  test(target, data) {
    console.log(target)
    console.log(data)
  }
  // update (dt) {}
}
